home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 17
/
CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso
/
CUCD
/
Online
/
News
/
Thor
/
HD-Install
/
thor.lha
/
rexx
/
CfgHTTP.thor
< prev
next >
Wrap
Text File
|
1997-04-27
|
9KB
|
363 lines
/*
$VER: CfgHTTP.thor 0.2 (22.2.97)
by Remco van Hooff
Configuration editor for http.thor
History:
0.1 - First test release.
0.2 - Forgot to save the browserexe config.
- Removed some text that were letf in when using code from CfgGetNET.
*/
/*!~ "Variables" */
version = SUBWORD(SOURCELINE(2), 3,1)
cfgpath = 'env:thor/'
cfgfile = 'http.config'
change = 0
title = 'CfgHTTP' version '© by Remco van Hooff'
/*~!*/
/*!~ "Init" */
OPTIONS RESULTS
/*TRACE RESULTS*/
p=' '||ADDRESS()||' '||SHOW('P',,)
IF POS(' THOR.',p)>0 THEN thorport=WORD(SUBSTR(p,POS(' THOR.',p)+1),1)
ELSE DO
SAY 'THOR port not found!'
EXIT 10
END
IF ~SHOW('p', 'BBSREAD') THEN DO
ADDRESS COMMAND
"run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
END
/*~!*/
CALL loadprefs
CALL cfgmain
EXIT
/*!~ "LoadPrefs" */
loadprefs:
IF ~EXISTS(cfgpath||cfgfile) THEN DO
Address(thorport)
'Requestnotify TEXT "Could not find the configuration file.\nUsing the default settings." BT "_OK"'
Call checkprefs
END
ELSE DO
CALL OPEN(prf,cfgpath||cfgfile,'R')
DO UNTIL EOF(prf)
line = READLN(prf)
SELECT
WHEN UPPER(WORD(line,1)) = 'GETNET' THEN DO
getnet = SUBWORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'BROWSER' THEN DO
browser = WORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'BROWSEREXE' THEN DO
browserexe = SUBWORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'SAVE_URL' THEN DO
save_url = WORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'SAVEDELAY' THEN DO
savedelay = WORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'AWEB_TCP' THEN DO
aweb_tcp = WORD(line,2)
END
WHEN UPPER(WORD(line,1)) = 'TCP_IP' THEN DO
tcp_ip = SUBWORD(line,2)
END
OTHERWISE NOP
END
END
CALL CLOSE(prf)
CALL checkprefs
END
RETURN
/*~!*/
/*!~ "CheckPrefs" */
checkprefs:
IF (SYMBOL('getnet') ~= 'VAR' | getnet = '') THEN DO
CALL OPEN(tmp, 'env:thor/thorpath')
thorpath = readln(tmp)
CALL CLOSE(tmp)
getnet = thorpath'rexx/getnet.thor'
END
IF ~DATATYPE(browser, 'NUM') THEN browser = 4
IF (SYMBOL('browserexe') ~= 'VAR' | browserexe = '') THEN browserexe = 'voyager:v'
IF ~DATATYPE(save_url, 'BIN') THEN save_url = 0
IF ~DATATYPE(savedelay, 'NUM') THEN savedelay = 5
IF ~DATATYPE(aweb_tcp, 'BIN') THEN aweb_tcp = 0
IF (SYMBOL('tcp_ip') ~= 'VAR' | tcp_ip = '') THEN tcp_ip = 'RequestChoice >NIL: TITLE="HTTP.thor ERROR" BODY="No TCP/IP stack to run. Use CfgHTTP to edit." GADGETS="OK" Pubscreen=Thor.1'
RETURN
/*~!*/
/*!~ "SavePrefs" */
saveprefs:
CALL OPEN(prf,cfgpath||cfgfile,'W')
CALL WRITELN(prf,'GETNET' getnet)
CALL WRITELN(prf,'BROWSER' browser)
CALL WRITELN(prf,'BROWSEREXE' browserexe)
CALL WRITELN(prf,'SAVE_URL' save_url)
CALL WRITELN(prf,'SAVEDELAY' savedelay)
CALL WRITELN(prf,'AWEB_TCP' aweb_tcp)
CALL WRITELN(prf,'TCP_IP' tcp_ip)
CALL CLOSE(prf)
ADDRESS command 'Copy "'cfgpath||cfgfile'" "ENVARC:Thor/" QUIET'
RETURN
/*~!*/
/*!~ "CfgMain" */
cfgmain:
SELECT
WHEN save_url = 0 THEN sv = 'No'
WHEN save_url = 1 THEN sv = 'Yes'
OTHERWISE sv = '?'
END
SELECT
WHEN aweb_tcp = 0 THEN aw = 'No'
WHEN aweb_tcp = 1 THEN aw = 'Yes'
OTHERWISE aw = '?'
END
SELECT
WHEN browser = '1' THEN br = 'IBrowse'
WHEN browser = '2' THEN br = 'AWeb'
WHEN browser = '3' THEN br = 'AMosaic'
WHEN browser = '4' THEN br = 'Voyager'
OTHERWISE br = '?'
END
main.1 = 'GetNET path :' getnet
main.2 = 'Browser name :' br
main.3 = 'Browser path :' browserexe
main.4 = 'TCP/IP start :' LEFT(tcp_ip,30)
main.5 = ''
main.6 = 'Save and exit'
main.count = 6
SELECT
WHEN (browser = 1) THEN DO
main.5 = 'Save URL :' sv
main.6 = 'Save delay :' savedelay
main.7 = ''
main.8 = 'Save and exit'
main.count = 8
END
WHEN (browser = 2) THEN DO
IF aweb_tcp THEN DO
main.4 = 'AWeb TCP/IP :' aw
main.5 = ''
main.6 = 'Save and exit'
main.count = 6
END
ELSE DO
main.4 = 'AWeb TCP/IP :' aw
main.5 = 'TCP/IP start :' LEFT(tcp_ip,30)
main.6 = ''
main.7 = 'Save and exit'
main.count = 7
END
END
OTHERWISE NOP
END
ADDRESS(thorport)
'REQUESTLIST INSTEM' main 'TITLE "'title'" SIZEGADGET'
IF (RC = 30) THEN DO
'REQUESTNOTIFY TEXT "'THOR.LASTERROR'" BT "_Ok"'
EXIT
END
IF RC = 5 THEN DO
IF change THEN DO
'REQUESTNOTIFY TEXT "Are you sure you want to\nexit without saving?" BT "_Yes|_No"'
IF RC = 0 THEN DO
IF RESULT = 1 THEN EXIT
IF RESULT = 0 THEN SIGNAL cfgmain
END
END
END
ELSE DO
selected = RESULT
SELECT
WHEN POS('GetNET path',selected) ~= 0 THEN DO
CALL request_file('Select the path to GetNET', getnet)
getnet = RESULT
SIGNAL cfgmain
END
WHEN POS('Browser name', selected) ~= 0 THEN DO
CALL sel_browser
SIGNAL cfgmain
END
WHEN Pos('Browser path', selected) ~= 0 THEN DO
CALL request_file('Select the path to your Browser', browserexe)
browserexe = RESULT
SIGNAL cfgmain
END
WHEN Pos('TCP/IP start', selected) ~= 0 THEN DO
'REQUESTSTRING TITLE "'title'" BODY "Enter a command to start your\nTCP-IP stack." BT "_OK|_Cancel" MAXCHARS 256 ID "'addasterix(tcp_ip)'"'
IF (RC = 30) THEN DO
'REQUESTNOTIFY TEXT "'THOR.LASTERROR'" BT "_Ok"'
EXIT
END
IF RC = 5 THEN SIGNAL cfgmain
IF RC = 0 THEN DO
IF THORRC = 1 then tcp_ip = RESULT
END
SIGNAL cfgmain
END
WHEN POS('Save URL', selected) ~= 0 THEN DO
save_url = askYN('Save the URL directly to the IBrowse hotlist?\n\nCurrently:' sv, save_url, '_Yes|_No')
SIGNAL cfgmain
END
WHEN POS('Save delay', selected) ~= 0 THEN DO
savedelay = asknum('Enter the save delay', savedelay)
SIGNAL cfgmain
END
WHEN POS('AWeb TCP/IP', selected) ~= 0 THEN DO
aweb_tcp = askYN('Use the built-in TCP/IP starting\nfeature of AWeb?\n\nCurrently:' aw, aweb_tcp, '_Yes|_No')
SIGNAL cfgmain
END
WHEN selected = 'Save and exit' THEN DO
CALL saveprefs
EXIT
END
OTHERWISE CALL cfgmain
END
END
RETURN
/*~!*/
/*!~ "Select browser"*/
sel_browser:
drop brow.
brow.1 = 'AMosaic'
brow.2 = 'AWeb'
brow.3 = 'IBrowse'
brow.4 = 'Voyager'
brow.count = 4
ADDRESS(thorport)
'REQUESTLIST INSTEM' brow 'TITLE "Select your browser." SIZEGADGET'
IF (RC = 30) THEN DO
'REQUESTNOTIFY TEXT "'THOR.LASTERROR'" BT "_Ok"'
EXIT
END
IF RC = 5 THEN RETURN
ELSE DO
brw = RESULT
SELECT
WHEN POS('AMOSAIC', UPPER(brw)) ~=0 THEN browser = 3
WHEN POS('AWEB', UPPER(brw)) ~=0 THEN browser = 2
WHEN POS('IBROWSE', UPPER(brw)) ~=0 THEN browser = 1
WHEN POS('VOYAGER', UPPER(brw)) ~=0 THEN browser = 4
END
END
RETURN
/*~!*/
/*!~ "Request_File" */
request_file:
reqtitle = ARG(1)
dir = ARG(2)
filepos = LastPos('/', dir)
IF filepos = 0 THEN filepos = LastPos(':', dir)
file = substr(dir,filepos+1)
filedir = substr(dir,1,filepos)
'REQUESTFILE TITLE "'reqtitle'" ID "'filedir'" IF "'file'" FP'
IF (RC = 30) THEN DO
'REQUESTNOTIFY TEXT "'THOR.LASTERROR'" BT "_Ok"'
EXIT
END
IF RC = 5 THEN RETURN ARG(2)
IF RC = 0 THEN DO
dir2 = dir
dir = RESULT
IF dir2 ~= dir THEN change = 1
END
RETURN dir
/*~!*/
/*!~ "AskYN" */
askYN:
reqtxt = ARG(1)
option = ARG(2)
buttons = ARG(3)
'REQUESTNOTIFY TEXT "'reqtxt'" BT "'buttons'"'
IF RC = 0 THEN DO
IF RESULT = 1 THEN DO
IF option = 0 THEN change = 1
option = 1
END
IF RESULT = 0 THEN DO
IF option = 1 THEN change = 1
option = 0
END
END
RETURN(option)
/*~!*/
/*!~ "AddAsterix" */
/* From CfgSortMail.thor by Eirik Nicolai Synnes */
addasterix:
str = ARG(1)
IF str = '' THEN RETURN(str)
lastfound = 0; found = INDEX(str, '*')
DO WHILE found > lastfound
secondpart = SUBSTR(str, found + LENGTH('*'))
firstpart = SUBSTR(str, 1, LENGTH(str) - LENGTH(SUBSTR(str, found)))
str = firstpart || '**' || secondpart
lastfound = found + LENGTH('**')
found = INDEX(str, '*', lastfound)
END
lastfound = 0; found = INDEX(str, '"')
DO WHILE found > lastfound
secondpart = SUBSTR(str, found + LENGTH('"'))
firstpart = SUBSTR(str, 1, LENGTH(str) - LENGTH(SUBSTR(str, found)))
str = firstpart || '*"' || secondpart
lastfound = found + LENGTH('*"')
found = INDEX(str, '"', lastfound)
END
RETURN(str)
/*~!*/
/*!~ "Aksnum"*/
asknum:
ADDRESS(thorport)
'REQUESTINTEGER MIN 0 MAX 60 INIT' ARG(2) 'TITLE "'ARG(1)'" BT "_Ok|_Cancel"'
IF (RC = 30) THEN DO
'REQUESTNOTIFY TEXT "'THOR.LASTERROR'" BT "_Ok"'
EXIT
END
IF RC = 5 THEN RETURN ARG(2)
IF RC = 0 THEN DO
num2 = num
num = RESULT
IF num2 ~= num THEN change = 1
END
RETURN num
/*~!*/